#pragma once
#include <string>


class Vertex;

enum EdgeType	{BLACK, WHITE, eCLEAR};


struct qualityCompareSet_Edge
{
	template <typename PtrType>
	bool operator () (const PtrType &pT1, const PtrType &pT2) const
	{
		return   *pT1 < *pT2;
	}
};

class Edge
{
private:
	Vertex			*contact1,
					*contact2;

	string			data;

	float			w;

public:
	EdgeType				Type;

	Edge					(Vertex* Vertex_Creater, float new_W)
	{
		contact1		= Vertex_Creater;
		contact2		= NULL;

		Type			= eCLEAR;

		w				= new_W;
	}

	Vertex*	getOtherVertex	(Vertex*	this_Vertex, bool Directed)
	{
		if (this_Vertex == contact1)
		{
			Type = WHITE;
			return contact2;
		}

		if (!Directed && this_Vertex == contact2)
		{
			Type = BLACK;
			return contact1;
		}

		return NULL;
	}
	Vertex* getFirstVertex	()
	{
		return contact1;
	}
	Vertex* getSecondVertex	()
	{
		return contact2;
	}
	bool	addVertex		(Vertex* new_Vertex)
	{
		contact2	=	new_Vertex;

		if (contact2 == NULL)
			return false;

		return true;
	}
	bool	reconnect		(Vertex* new_Vertex)
	{
		return addVertex(new_Vertex);
	}
	float	getW			()
	{
		return w;
	}

	bool operator <  (Edge &Obj)
	{
		return w < Obj.getW();
	}
	bool operator >  (Edge &Obj)
	{
		return w > Obj.getW();
	}
	bool operator <= (Edge &Obj)
	{
		return w < Obj.getW() && *this == Obj;
	}
	bool operator >= (Edge &Obj)
	{
		return w > Obj.getW() && *this == Obj;
	}
	bool operator == (Edge &Obj)
	{
		return w == Obj.getW() 
			&& 
			((contact1 == Obj.getFirstVertex() && contact2 == Obj.getSecondVertex()) 
			||
			(contact2 == Obj.getFirstVertex() && contact1 == Obj.getSecondVertex()));
	}
};

bool	qualityCompare_Edge (Edge* &lObj, Edge* &rObj)
{
	return *lObj < *rObj;
}

// -=BAIZOR=-